package com.apinoo.users.domain;

import javax.persistence.Embeddable;
import javax.persistence.ManyToOne;

@Embeddable
public class UserGroupId implements java.io.Serializable {


	private User user;

	private Group group;

	@ManyToOne
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@ManyToOne
	public Group getGroup() {
		return group;
	}

	public void setGroup(Group group) {
		this.group = group;
	}

	public boolean equals(Object o) {
		if ( this == o) return true;
		if (o == null || getClass() != o.getClass()) return false;
		
		UserGroupId that = (UserGroupId) o;
		
		if ( user != null ? !user.equals(that.user) : that.user != null) return false;
		if ( group != null ? !group.equals(that.group) : that.group != null) return false;
		
		return true;
	}
	
	public int hashCode() {
		int result;
		result = (user != null ? user.hashCode() : 0);
		result = 31 * result + ( group != null ? group.hashCode() : 0);
		return result;
	}
}
